package com.changgou.backend.controller;

import com.changgou.entity.Result;
import com.changgou.goods.feign.SkuFeign;
import com.changgou.goods.pojo.Sku;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author xuchangshuo
 * @date 2020/7/29 18:05
 */
@RestController
@RequestMapping("/findSKu")
public class SkuController {


    @Autowired
    private SkuFeign skuFeign;

    //查询所有sku商品
    @RequestMapping("/findPage/{page}/{size}")
    public Result findPage(@RequestBody Map<String, String> map, @PathVariable("page") int page, @PathVariable("size") int size) {
        Result result = skuFeign.findPage(map, page, size);
        return result;
    }

    //根据id删除sku
    @ResponseBody
    @RequestMapping("/delete")
    public Result delete(@RequestParam String id) {
        Result result = skuFeign.delete(id);
        return result;
    }

    //根据id查询sku
    @ResponseBody
    @RequestMapping("/findSkuById")
    public Result findSkuById(@RequestParam String id) {
        Result<Sku> result = skuFeign.findById(id);
        return result;
    }

    //编辑sku
    @ResponseBody
    @RequestMapping("/updete")
   public Result updete(@RequestBody Sku sku){
        String id = sku.getId();
        Result result = skuFeign.update(sku, id);
        return result;
    }

//    //条件查询
//    @ResponseBody
//    @RequestMapping("/query")
//    public Result query(@RequestParam Map map,@RequestParam int page,@RequestParam int size){
//        Result result = skuFeign.findPage(map, page, size);
//        return result;
//    }

}
